mod ue_thread;
mod up_thread;

use std::error::Error;
use std::thread;
use icc_server::IccParam;

fn main() -> Result<(), Box<dyn Error>> 
{
    let file_path = "rs_param.json";
    let icc_param = IccParam::parse_and_build(file_path)?;
    let icc_param1 = icc_param.clone(); //必须拷贝，每个线程都要拿走所有权

    let version = "v1.0.2";
    println!("icc server version:{}" , version);
    
    // 创建线程来处理第一个监听器的连接
    let handle1 = thread::spawn(move || {
        let _ = ue_thread::handle_client(icc_param);
    });

    // 创建线程来处理第二个监听器的连接
    let handle2 = thread::spawn(move || {
        let _ = up_thread::handle_client(&icc_param1);
    });

    // 等待两个线程完成
    handle1.join().unwrap();
    handle2.join().unwrap();

    Ok(())
}
